package ms.jacrim.tropos;

import org.w3c.dom.Element;

public class Contribution extends Relationship {
	private static final String CONTRIBUTION_TEMPLATE = "<object xmi:type=\"%s\" xmi:id=\"%s\""
			+ " source=\"%s\" target=\"%s\" contributionType=\"%s\" relationshipType=\"%s\" satType=\"%s\"/>\r\n";

	private String contributionType, relationshipType, satType;

	public Contribution(Diagram diagram, TroposObject source, TroposObject target) {
		super(diagram, source, target);
		setType(TroposObject.CONTRIBUTION);
	}

	public Contribution(Diagram diagram, Element element) {
		super(diagram, element);
	}

	void populate(Element element) {
		super.populate(element);

		this.contributionType = element.getAttribute("compositionType");
		this.relationshipType = element.getAttribute("relationshipType");
		this.satType = element.getAttribute("satType");
	}

	public String getContributionType() {
		return contributionType;
	}

	public void setContributionType(String contributionType) {
		this.contributionType = contributionType;
	}

	public String getRelationshipType() {
		return relationshipType;
	}

	public void setRelationshipType(String relationshipType) {
		this.relationshipType = relationshipType;
	}

	public String getSatType() {
		return satType;
	}

	public void setSatType(String satType) {
		this.satType = satType;
	}

	void toString(StringBuilder result, int part, int indent) {
		writeIndent(result, indent);
		result.append(String.format(CONTRIBUTION_TEMPLATE, this.getType(), this.getId(), this.getSourceId(), this.getTargetId(),
				this.contributionType, this.relationshipType, this.satType));
	}

	@Override
	protected int NotationEdgeType() {
		// TODO Auto-generated method stub
		return 0;
	}
}
